package com.heima.article.feign;

import com.heima.article.service.ApArticleService;
import com.heima.feign.article.IArticleClient;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ArticleClient implements IArticleClient {
    /**
     * 实现feign接口
     * app端文章保存
     * */
    @Autowired
    private ApArticleService apArticleService;

    @PostMapping("/api/v1/article/save")
    public ResponseResult saveOrUpdate(@RequestBody ArticleDto articleDto) {
        /*try {
            Thread.sleep(3000);//人为模拟故障
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/
        return apArticleService.saveArticle(articleDto);
    }
}
